minor refactoring, add boolean test