Fix variable type in loop (we need uint16 instead of uint8)