added self.error_occured so that done is not emmited if an error has occured