cleaning up api.js