Added method to flatted nested arrays into a single array