Pull function out of loop.