improve worker function