Better line-drawing implementation