ending heuristic functions added.