JS speed optimization. Thanks to dimistor.