ignoring address and command bytes, pulling repeated code into function