fixed delete logic