p function is working fine