This is one for finding the previous operation, you can probably modify it to find the next operation.