added event cancelling code