heuristic refactor