Improved code. Part 1