Made heuristic more accurate