added a basic code to support count().