fully implemented item counting