Added array size check.