Added writing of mesage to memory