Remove duplicate if/else block