q5: Generalize beta expression