fixed bugs in the heuristic pattern