Modify search function to use heuristic function if any