change read in to sys.stdin
typeahead success, fix bug