refactoring and generic PrimesGenerator