drawing logic