how do thoughts work