example 8-3: message counter