rewrote the cnn data functions