Problem 009 refactor