added code for p