train function added to network