refactor for remove duplication in each class