Update do_costdivide.js for error checking