refactoring and fix