Nit: why not just check `name` here, and `count` after the loop rather than combining?