refactor window open