finished first draft of line detection