Add countFields function.