Modified count() method