A full code refactoring