Small refactoring to DRY the code for matching white spaces