messages logic