Moving functions from index.js to services