more reductions in code lines and increased use of mapping and functions, still need to implement better practices on main for loop