updated to support multi windows