cleaned up onbeforeunload