refactoring into service