Another approach for task 4