cleaning and refactoring