Moved function to worker