Fix bug in A*