window api change and refactoring