Added functions to handle the different message types