 
         // Check if spike occurred within the last timestep    
 	for (int g=0; g < timestep_grouping; g++){
-          if (fabs(effecttime - (current_time_in_seconds + g*timestep)) < 0.5*timestep){
+          if (fabs((effecttime + g*timestep) - current_time_in_seconds) < (0.5*timestep)){
             // For each of this neuron's efferent synapses
             for (int i = 0; i < synapse_count; i++){
               int synapse_id = presynaptic_is_input ? d_per_input_neuron_efferent_synapse_indices[d_per_input_neuron_efferent_synapse_total[corr_idx] - i - 1] : d_per_neuron_efferent_synapse_indices[d_per_neuron_efferent_synapse_total[corr_idx] - i - 1];

      int indx = threadIdx.x + blockIdx.x * blockDim.x;
      while (indx < total_number_of_neurons) {
	if (indx == 0){
	  int previd = ((bufferloc - 1) < 0) ? (buffersize - 1): (bufferloc - 1);
	  circular_spikenum_buffer[previd] = 0;
	}
		
   	int idx = indx - (num_input_neurons); 

      int indx = threadIdx.x + blockIdx.x * blockDim.x;

      for (int g=0; g < timestep_grouping; g++){
	int tmpbufferloc = (bufferloc + g) % buffersize;
        while (indx < circular_spikenum_buffer[tmpbufferloc]) {
         int idx = spikeid_buffer[tmpbufferloc*total_number_of_synapses + indx];
       
         // Update Synapses
         d_time_of_last_spike_to_reach_synapse[idx] = current_time_in_seconds + g*timestep;
         int postsynaptic_neuron_id = postsynaptic_neuron_indices[idx];
         int trace_id = synaptic_decay_id[idx];
         float synaptic_efficacy = d_biological_conductance_scaling_constants_lambda[idx] * d_synaptic_efficacies_or_weights[idx];
