Used a recursive approach to avoid the upload error