check index type and fix $j[] for bitsets