improved implementation for switching between windows.