added second heuristics
slightly modified main heuristics