Fix bug in sendMessage