Updated logic to compute the size of the array