simplify code around should_match?
remove trailing white spaces