Improved compatibility with different array types