Update sendMessage function.