fixed script worker function