Refactoring comparison code; persisting results in peewee