Add conditions for consistency of array dimension