Refactoring logic for creating and deleting members