Optimized parsing code (JavaScript)