refactored and tested 500th prime