Working with Heuristic function.