tiny refactorings for outputting error message

- cosmetic change
- use a simpler predicate