some js code cleanup