use elsif, factor the assignment out