move upload to script section so can fail properly