first stages of A* implementation