refactored the example