added error verification on sendMsg