some JS code clean up