add logic code to message handling