restructure function g
reformat sbox