testing and refactored problem 2