issue #332. Implemented the reverse function to uphold DRY.