slight changes for testgng, some code moved to copy