Refactored delete_by functions