added pathfinding code