Updated line recognizing algorithm.