<!-- canonical: https://0xsimao.com/findings/glacier-statements-inverted-increase-readability -->

# If statements can be inverted to increase readability

Low/Info · Three Sigma · Liquid staking · 12th July, 2023

Finding 3S-GLACIER-N06 of the Glacier security review.

- Protocol: https://www.glacier.io/
- Report: /reports/glacier
- Source: https://cdn.sanity.io/files/qoqld077/production/21bd3b6fa78c55968a6c9c7ea4fd49f34a8bd3d8.pdf

---

### Description

Inverting if statements can help increase readability and decrease overall code complexity.

### Recommendation

Take a look at the following example.

```solidity
function withdraw(uint256 amount) external nonReentrant {
    ... if (toWithdraw > 0) {
```

<code when toWithdraw > 0>

```solidity
}
emit Withdraw(user, totalWithdrawAvaxAmount);
}
```

It can be replaced by

```solidity
function withdraw(uint256 amount) external nonReentrant {
    ... emit Withdraw(user, totalWithdrawAvaxAmount);
    if (toWithdraw <= 0) return;
```

<code when toWithdraw > 0>
}

### Status

Currently being reviewed by the team.

---

Related findings:

- [Admin checks in KeyringCoreV2Base could be placed in a modifier to increase readability and reduce code duplication](https://0xsimao.com/findings/keyring-ii-placed-readability-reduce-duplication): Keyring Credentials
