Updated the code for heuristics