simplify if-else structure