fixed upload
removed lots of code, refactoring