Fix bug emitting error