Finished first and second task of third homework