code for ex2