refactor with inheritance