fixes bug in reduce_db.py