code refactoring. remove duplicated method and make some method to class method.