Make set text by enter, make ctrl+z work and refactored code.