move thread workers to functions