refactoring api service side