added active window function
Some changes