> For the complete documentation index, see [llms.txt](https://docs.work-relay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.work-relay.com/automations/functions-and-formulas/hints-and-best-practices.md).

# Hints and best practices

## Formulas evaluation optimization

Work-Relay application have an optimization feature that works on formulas: if same formula is used several times on the page, it will be calculated once and then re-used.

This feature makes better performance, but in some situations this may cause a trouble. For example, you need to create a set of variables with random values with a [Global Action](/automations/global-actions-and-action-groups/basics/introduction-to-actions-and-action-groups.md):

![](/files/bff57ff1fe5e86681bdfe6020969fa658fc598e7)

If use `RANDOM()` function, same formula will return the same value. The following code:

```json
{
"var1":"FORMULA[RANDOM()]",
"var2":"FORMULA[RANDOM()]",
"var3":"FORMULA[RANDOM()]",
"var4":"FORMULA[RANDOM()]",
"var5":"FORMULA[RANDOM()]"
}
```

will actually return result like this, and all variables will have the same value:

```json
{
"var1":"1206324011544567911",
"var2":"1206324011544567911",
"var3":"1206324011544567911",
"var4":"1206324011544567911",
"var5":"1206324011544567911"
}
```

The first way to avoid this is make each formula unique. This can be simply done by adding unique arguments to function (`RANDOM()` function ignores arguments). This code:

```json
{
"var1":"FORMULA[RANDOM()]",
"var2":"FORMULA[RANDOM(1)]",
"var3":"FORMULA[RANDOM(2)]",
"var4":"FORMULA[RANDOM(a)]",
"var5":"FORMULA[RANDOM('qwerty')]"
}
```

will return different results as expected:

```json
{
"var1":"2506444008547775918",
"var2":"-4272344904841138045",
"var3":"6437921611015627107",
"var4":"-6020554262958932056",
"var5":"-3528369270255742994"
}
```

Another way to solve this situation is to make all necessary function calls in one formula - each time function will be called again. This code:

```json
FORMULA[
'{"var1":"' + TEXT(RANDOM()) + 
'","var2":"' + TEXT(RANDOM()) + 
'","var3":"' + TEXT(RANDOM()) +
'","var4":"' + TEXT(RANDOM()) +
'","var5":"' + TEXT(RANDOM()) +
'"}']
```

will return correct result (JSON text):

{% code overflow="wrap" %}

```json
{"var1":"-7277966880876800456","var2":"-3968577798298648346","var3":"-883462064986564523","var4":"99229509701172936","var5":"8738940707593593542"}
```

{% endcode %}
