trim variables before filtering to avoid side effects.