Refactoring for exercise four.