completed reverse function