added training function - backpropagation