Change two if-else constructions