Optimized JavaScript code