refactoring and code commenting