refactored problem function generation