Check for key before deleting it in middleware