major restructing of jtag code