Adjusted astar to take in isGoal Function or a goal state