added logic to js to determine what page is loaded and act accordingly, needs refinement