fixed doubling back problem