Origin of thoughts: how thinking works