refactored definition service creation into its own factory