fix duplicate if/else branches