write twitter data processing function