fix bug in count_items