Refactoring of the code