Wrote reverse function