trying to tweak the getBgCounts function