fixed bugs with event emission