made tiny optimalisation in primes