clean code for TextBuffer