moved upload code to model