adding p_mg to more functions