same function is used in the messagelistmodel.