add progress bar when loading
refactor api, add test case