solution to reverseBetween