refactoring of window call in class