fix a bug in popstate