Updated upload function