Added synchronization to prevent concurrency exceptions