Change class conditional to use instanceof