changed to throwing error rather than emitting