JavaScript util code