add ex3 code