modifications to upload script. PLEASE REGRESSION TEST