fix heuristic function