fixed a bug in invoking sendMessage()