use max var rather than pre-computing p (temp fix)