Refactoring to unify crud logic