added error handling if opcode is invalid