Updated itemcount.

Wrote a shorter and cleaner version.