de-noobed some js code