Restored old implementation of count