Code refactoring in service. App doesn't work yet