formatting and remove trailing spaces