Now always getting the right counts but sometimes getting the wrong ranges