more refactoring and styling