changed the code to trim the texts

changed the code to trim the texts