Added index check to return data array.