finished second draft of line detection