handle NA's in indices, handle logical indices