messaging function implementation