Rewrote scripts to reduce complexity due to rubocop concerns