refactored primesTo