added efficient method for finding prime