code refactor for plan and card update