new implementation of reverseString