Updated sieve algorithm