added onbeforeunload event