Refactor: Shorten code inside isInstance()