Handles not nested arrays
Little refactoring