Probably better to move this to the top of the function where we can also use it in those `if` checks.