minor code refactoring
simplified and refactored window