Refactoring p10 sieve solution