Moved assist code to separate function

no changes in functionality.