Added a refresh function and changed sendMessage to postMessage.
Function postMessage now calls refresh function.