reverse by hand implemented along with test