fixed error in unload and load event