Moved the distance check for d_line to the top