Working version of task4