Use counter cache instead of recursion