refactoring and comments