fixed reference error for error emitting