Pass window reference and fix string build