updated event logic