fix bug in fork worker function