Simplify if-else logics