Refactoring and remove warning