Added function to remove trailing whitespace