refactor bidx code into object
refactor most bidx js into separate bidx.js file