Fixed a bug in message counter