added query_psa.pl; added initial checks