trim text before inserting into brackets