Fixing line drawing algorithm