fix upload function