fixed error in sendmessage function