refactor for using sendMessage to load a new page