code is error free using class inheritance refactor 4