rewriten code for line detection, lines are now detected nicely, i have to merge them somehow