changed gather to take unsigned char arrays