Move function out of closure