How do I get the link variable in the if statement to modify the one in the scope of the method?