fixed matching on extra characters at end of string