getting rid of nested for loops in draw line