replaced upload function