refactored bde-js.js