Minor modification to heuristic function