Fix conditional that throws exception