updated heuristic function