Refactoring final implementation