algo for reversing a string