Fixed optimization error with if/else.