Refactored the heuristics