add download functions ,fixed some bugs