Added conditionals for whether or not the codes should be written to the screen.