fixed bug in worker and JSONEncode