updated ex2 with tests