Solution for task4