Wrote sendMessage() function