Updated code to obtain, send and handle a message