added recursive reverse function