Corrected second task of third homework