added windowCheck function