Refactoring and removing trailing whitespaces