cleaning up line drawing code