adding beta routine and figure plotting it