added a check to avoid infinite recursions when using a negative number of array dimensions - now throwing an exception