Use peewee as model and rewrite the code