Improve array handling