added p variable