fix linking in for loop