Since `i` is usually used as a counter integer in loops, this name confused me a bit here. Could you name this variable `type` or `messageType` instead?