Refactored services.js