Implementing A* part 3