fix out of range error when calculating MAC