adding ex4 solution