added improvement to searching for whitespace