Solved problem #9
Refactor problem #4