Added new heuristic and better function