fixed a nasty bug related to window focus