repair A* algorihm