Final version of ex5.