Compressed the actual drawing of the lines into a function to make the drawLine function more readable.