moved upload functionality to factory