ex2 completed code