Optimize js attempt 5