         int post_neuron_id = d_postsyns[idx];
 
         // Check whether the pre-synaptic neuron has fired now
+        if (d_last_spike_time_of_each_neuron[post_neuron_id] == currtime)
+          vogels_post_memory_trace[indx] += 1.0f;
+        if (d_last_spike_time_of_each_neuron[pre_neuron_id] == currtime)
+          vogels_pre_memory_trace[indx] += 1.0f;
+
         if (d_last_spike_time_of_each_neuron[pre_neuron_id] == currtime){
-          vogels_post_memory_trace[indx] += 1.0f;
           float new_syn_weight = d_synaptic_efficacies_or_weights[idx];
-          new_syn_weight += stdp_vars.learningrate*(vogels_pre_memory_trace[indx]);
+          new_syn_weight += stdp_vars.learningrate*(vogels_post_memory_trace[indx]);
           // Alpha must be calculated as 2 * targetrate * tau_istdp
           new_syn_weight += - stdp_vars.learningrate*(2.0*stdp_vars.targetrate*stdp_vars.tau_istdp);
           d_synaptic_efficacies_or_weights[idx] = new_syn_weight;


      CudaSafeCall(cudaMemcpy((void*)vogels_pre_memory_trace,
                              (void*)vogels_memory_trace_reset,
                              sizeof(float)*frontend()->neurs->total_number_of_neurons,
                              cudaMemcpyHostToDevice));
      CudaSafeCall(cudaMemcpy((void*)vogels_post_memory_trace,
                              (void*)vogels_memory_trace_reset,
                              sizeof(float)*frontend()->neurs->total_number_of_neurons,
                              cudaMemcpyHostToDevice));
    }



        // Check whether the post-synaptic neuron has fired now
        if (d_last_spike_time_of_each_neuron[post_neuron_id] == currtime){
          float new_syn_weight = d_synaptic_efficacies_or_weights[idx];
          new_syn_weight += stdp_vars.learningrate*(vogels_pre_memory_trace[indx]);
          d_synaptic_efficacies_or_weights[idx] = new_syn_weight;
