Changed the code so that the onProgress and the onError event is triggered