converted reverse string commands to functions