Upload works, but needs some refactoring