@vojtajina - This function was originally just a block of code.  It could still be as it is only called once.  Should we revert that, since I guess that creating a function in here is a performance cost?