commenting and refactoring code