problem14 refactor