update comments and refactoring