moved sendMessage function outside web.js to prepare for adding more functionalities