Restructuring and refactoring of the code