Fix bug in emit()