Use if-else to make nesting clearer