Changed event handler to a more compatible one