New template drawing logic