We need to refactor the processinstanceHelper class.
There are multiple code duplications and complexity that can be reduced to improve readability of the code