finished rewriting services.js