Refactored exercise