fixed events and close function