improved prime search functionality, but still slow brute force