improve remove_trailing_space