Use slightly more efficient method.

Thanks Péter Szücs.