script to check for referrals