Refactored Exercise 3