fixed sending message function