simplify code, and test with tools/htdocs/mkws-complete.js, MKWS-282