beta problem1b, need further debugging