fixing synchronization bug