first working upload function