refactoring and style updates