pre rewrite drawing logic