Use type instead of instanceof