added a heuristic function