refactoring of problem complete