Updated function to handle new array structure
Updated function to handle new array structure