optimize upload script