added error arg for emit and iterate