Perhaps a switch statement would make it even easier to comprehend the logic.