reorganized system to prioritize checking directions closer to the goal