Added check for link field in the terminating WHERE clause