fixed bug with sync.Error at looping