refactored problem4 to remove feature envy