add twitter sample file and minor refactoring