Adding onError callback