updated ex3 solution