Fixed bug in automatic event definition