update and remove trailing space