formatting and refactoring