Added ex 3 solution