added some checks in heuristic solver