started modifying sql to follow SQLAlchemy expression paradigm