Added error checking to messaging