cleaned ifs in estimate distance