refactor service security