refactored to extract guard method