added function of onError handler