a little refactoring for Windows compatibility