implemented reverseText function