sorted index refactoring, work in progress