Organize JS code