started refactoring service.js