Added conditional for stripping trailing whitespaces