REFACTORING, refactor some method and logic