updated branch / shift

Updated branching to fix infinite looping and fixed shift registers.