added support for setting ttributedText directly
remove duplicate code