Added send message method

Moved sending of messages to its own method.