reordered check and whitespace strip