Handle correcly back/forward buttons