fix onError bugs