reverse function complete