Refactored delete_db method