Optimized Jscript code