Modified version of task4