line 563 (getkeys function): switch places p and q