refactoring availability logic