Final refactoring version