replaced "console.log" with an optional dependence on "debug."