Refactor: inlined the is* checks for speed improvements