improving memory management in worker