Fix logic to save P1 and P2 to DB