That did not work as expected because this would produce a hash with 'type' => 'count' for all existing types in the unread_notifications. What I need is 'name of type' => 'count' for all types the application knows. I changed the code you gave me and it works as expected. Would be nice if you could have a look at the new code.