Added ex 4 solution