completely rewrote neural network model