Converted array to a hash, reducing code by 68 lines.