Changed the text editng logic a bit

it will be better, especially memory management