modified insertMessage