fixing bug where null messages cause exception