debugged .reverse() function