Optimized JS code.
Refactored code.