add ex6 code