Fix issue when array is undefined