Refactoring, add comments