Problem 005 refactor