fixing reverse string function, added comments