improvement

- fix typo & some errors
- put loop process out from try-catch