custom functions to count number of spaces