formatting changes cont. and refactoring