implemented threshold-type line detection