How to check how many dimensions the arrays have