better handling for whitespace and autocomplete