Created heuristic function.