added most of backpropagation