move codes to window controller