Add function for worker thread.