How to handle multi-dimensional arrays