Refactored checking tables for values to a new helper function