CLC-3622 - Optimized Javascript conditional logic