change to onunload event