ex3 and updated ex1 code