adding a onError flag