Updated ex2 for homework