optimize the string reverse algorithm