added code for handling game events