updated to use events