factored out globals
factored out typeahead