working code, windows 7+ only