Corrected check in sendMessage