fix length check of array