reworked a, p and q