improve input method, which can deal with spaces now