fix doubling back bug