cleaning up JS code