was using the max index, when that is not yet set. Should have been sample counter