Fix: Don't make functions within a loop.