handling case 3 and 4, TODO handle byte for char, errorchk