function to trim whitespace