remove duplicated code in authplain