delete variables not used.
refactor code for #7

- use `var`,  not `:=`
- print when error occurred
- add comments