cleaned up the prime function some more