refactor and class inheritance