simplifed to using where instead of a new function each time. Also used
all to check for whitespace.