Extracting func def from loop