Exercise2 Refactored