move delete requests code to its own function