Change badBlockIndex to j+1