refactoring, add comments