update getTransformStream function

* add error checking safeguard
* update code to match the common core pattern