updated upload function