Changed structure of the code