add ex5 implementation.