moved dynamic code generation to a shared location