adding robust checks around the indexer loop to ensure the data is there