fixed upload algorithm