refactoring and comments
more refactoring and comments