Moved document creation to a prototype. Added simple value check on sendMessage as to prevent empty messages