updated code to make events