refactor non-idiomatic boolean check