refactor crud controller