restructuring and new text drawing logic