refactoring Element and removing spaces at the end of the line