Improve task's 3 code