Adding ex6 solution