fixing p_err less than zero