added unregister logic.