Couldn't most of this function be simplified to:

```lua
return process.env.STAGING or (b and b:lower() == 'true')
```