Added ex 6 solution