> For the complete documentation index, see [llms.txt](https://docs.r.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.r.xyz/glider-ide/api/instruction/instruction.previous_instruction.md).

# Instruction.previous\_instruction()

`previous_instruction() →` [`APISet`](/glider-ide/api/iterables/apiset.md)`[`[`Instruction`](/glider-ide/api/instruction.md)`]`

The difference between the previous\_instruction() function and [previous\_instructions()](/glider-ide/api/instruction/instruction.previous_instructions.md) is that this function will return a list of immediate previous instructions of the current instruction in the CFG (control-flow-graph).

*The function operates non-recursively, meaning it works intra-procedurally.*

For example, in the function:

```solidity
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }
```

for the instruction:&#x20;

```solidity
uint256 c = a - b;
```

the function will return the instruction:

```solidity
require(b <= a, errorMessage);
```

## Query Example

```python
from glider import *
def query():
  instructions = Functions().with_name("sub").exec(1,1).instructions().exec(1,2)

  return instructions + list(instructions[0].previous_instruction())
```

## Output Example

<figure><img src="/files/YKXN3caTAh5SKeVUIykn" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The function returns APISet, instead of APIList, in case the result of the function is used as the return value of the query it must be casted to `list()`
{% endhint %}
