fixing prep_sql and add_metric