Added some code to be refactored for Astar