adding logic for unlink and linked