Refactored drawing code
merged