Bug fix

- checking for presence of array and items in the array before trying
to iterate over them