added popstate function