Optimized the pollard row function