refactored twitter.js and api.js