Added onError event