add refresh function and fix event removal