refactor text drawing