unrolled the checking in decode_input a bit