added mode 2 with some test code.