add appservice
implement new logic and refactoring