added missing cleanup on failure