Sieve method

Optimized and changed the sieve function