Added personal heuristic. Cleaned code