Simplified code by writing a rule generator

Co-authored-by: Zach Allaun <zach@hackerschool.com>
Co-authored-by: Robert Buonpastore <robert.buonpastore@gmail.com>
Code Cleanup