Fixed add_to_db method