reverse words in a string explained