Refactoring code style about closure