Added e.preventDefault() so it stops changing the URL when switching between pages