refactored to use unless