extract whitespace detection into own function
slightly shorter expression