problem13 refactor