minor formatting changes and refactoring