Improving the structure of the code