implemented heuristic search