Reimplementation of countEntries