Fix and refactoring