bug fix of beta function