switch from message event to message function