fixed bugs in ex2