Redo code output for modularity and simplicity