refactored code and implemented a better separation between pathfinder and world