reorder bs-index generation
patched the segmentation fault