Synchronization code for now, might contain bugs