refactored crud