more formatting and refactoring