fix count function for function categories