refactoring function newIFrame to match public version