Delete algorithm