fix and refactoring