fully vectorized version of backward propagation