added ex1.2 code