task8 code optimization