added download method and fix some bugs