Refactoring and typo fixed