Implemenet heuristic functions