implemented unregister logic