idx should also be copied to the new window