implemented pathfinding