handle empty arrays

We cleaned up indentation and handled empty arrays.