Improved drawing code