replace bit-index lookups with a shift register