fix typo
put semi colons
put loop process out from try-catch