A* reimplementation