compacting drawing code