move currentResultIndex into scope