Refactor and add primes into hashmap