add onError handling