fixed bug in the generation of events