refactor problem 23