Fix error in expected output
Refactor condition for readability