What does it mean when `p` or `q` are nil? Should we add an else here (and switch to an if) to print a message if this happens?