UPDATED submitMessage function