refactored and passed seventh test