refactoring to eliminate availability bug