Changed delete to be a higher order function