improved implementation of spike_sync