Put the sieve in a separate function