Moved code into a seperate class for NN