Finish task4. Structure of code was changed.