added heuristic function