refactor joinPlan/leavePlan