case isn't necessary, if you increment an nonexistant hash element it is autocreated for you. Also, the
is superfluous since the order in which you look at your keys makes no difference to their count. And lastly, as has been pointed out, since you don't use the keys for anything else than to access the values, just use
. For code, see