Added error check when uploading