Fix typo and refactoring