fixed a bug with event generation