added onError stuff