refactored twitter codes