Added function for removing trailing whitespace