Added function for parsing messages