Improved task 31