Refactored to use events