bugfix onError funciotn