Add improved solution for task 3