added logic for add/update account