Refactoring and fix typo