Optimized drawing code