refactored ifExpression in preparation for casting infrastructure