function to eliminate trailing space