added suggested change from Edbert regarding end of string parsing