Updated SendMessage code