spaces and end of string are handled properly