improved the drawing code