removed dispose and added attach and detach virtual function called when such event happened