Changing the other if to also use typeof