having trouble with heuristic