fix getCounts function