version with logical indexing