Refactor: flip if to remove negation in if and name function