code cleanup, continue to modularize and reduce verbosity and complexity while maintaining function