pathfinding class code refactoring