fixing totalBits issue