Fix count functionality