changed variable n to p