rewrote js for qunit test