fix bug with distinct value counting