main logic moved to service class