Refactoring, comments added