Updating 'buildHeuristic()' function.